// ProcessHandle.h: interface for the CProcessHandle class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#include "GUI.h"

typedef struct _process_status_
{
	LONG					m_lProcessID; // Process ID, Not the Windows Process ID
	LPTSTR					m_lptProcessName;
	LPTSTR					m_lptCommandLine;
	PROCESS_INFORMATION		m_Process_Information;
	LONG					m_CurrentStatus;		// 0:Not Create,1: background, 
													// 2:Front

	HWND					m_hwCommunicationWindow; // Communication Window Handle.
}PROCESS_STATUS,*PPROCESS_STATUS;
#define  CPRROCESSMGR CProcessHandle::Instance()
class GUI_API CProcessHandle  
{
#define MAX_SUPPORT_PROCESS	31
public:
	static CProcessHandle& Instance(void);
	LONG KillAllProcess();
	LONG KillOneProcess(LONG lProcessID);
	LONG SetHostWindowHandle(HWND hWnd);
	HWND GetHostWindowHandle();
	BOOL IsAPRunning(LONG lProcessID);
	LONG RunOneProcess(LONG lProcessID);
	LONG BroadcastWindowMessage(UINT message, WPARAM wParam, LPARAM lParam);
	LONG SendWindowMessage(LONG lProcessID,UINT message, WPARAM wParam = 0, LPARAM lParam = NULL);
	LONG PostWindowMessage(LONG lProcessID,UINT message, WPARAM wParam = 0, LPARAM lParam = NULL);
	LONG PostThreadMessage(LONG lProcessID,UINT message, WPARAM wParam = 0, LPARAM lParam = NULL);
	LONG SetProcessWindowHandle(LONG lProcessID, HWND hWnd);
	LONG DeleteOneProcess(LONG lProcessID);
	LONG DeleteProcessByIndex(LONG lIndex);
	LONG InsertProcess(LONG lProcessID,LPCTSTR lpctProcessName = NULL,LPCTSTR lpctCommandLine = NULL);
	CProcessHandle(HWND hWndParent = NULL);
	virtual ~CProcessHandle();
private:
	LONG KillOneProcessByIndex(LONG iIndex);
	PROCESS_STATUS	m_ppsInfo[MAX_SUPPORT_PROCESS];
	HWND	m_hWndHost;
	CRITICAL_SECTION csNewProcess;
};


